﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Happy.Activities.Domain.Workflows.Internal
{
    internal static class SplitTokenHelper
    {
        internal const string DefaultSplitToken = "";

        internal const string Separator = "/";

        internal static string CombineSplitToken(string routerSplitToken, Guid activityInstanceId)
        {
            return routerSplitToken + Separator + activityInstanceId;
        }

        internal static string RemoveLastSplitToken(string splitToken)
        {
            var count = Separator.Length + Guid.Empty.ToString().Length;

            return splitToken.Remove(splitToken.Length - count, count);
        }

        internal static Guid GetLastSplitActivityInstanceId(string splitToken)
        {
            var length = Guid.Empty.ToString().Length;

            return new Guid(splitToken.Substring(splitToken.Length - length, length));
        }
    }
}
